package com.chanyachting.emall.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.chanyachting.emall.util.RequestUtil;

public class EmallservicesForm extends ActionForm {
	
	
	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.String optionType;  //对应操作类型
	private java.lang.String summary;		//功能服务说明
	private java.lang.Integer limitTime;  //限制次数
	private float servicePrice;	//功能服务价格
	private java.lang.Integer monthLimit;	//有效期，以月为单位
	private java.lang.String ifLimitTime;	//是否限制次数 00 不限制， 01 限制
	private java.lang.String serviceName;	//功能服务名称
	
	
	
	
	
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors=new ActionErrors();
		
		RequestUtil ru=new RequestUtil(request);
		
		if(this.getServiceName()==null ||this.getServiceName().trim().equals("")){
			
			ru.setMsg("名称不能为空！");
			
			errors.add("",new ActionMessage(""));
		}
		
		if(this.getMonthLimit()==null ||this.getMonthLimit()==0){
			
			ru.setMsg("有效期不能为空！");
			
			errors.add("",new ActionMessage(""));
		}
		
		
		if(this.getServicePrice()==0.00f){
			
			ru.setMsg("价格不能为空！");
			
			errors.add("",new ActionMessage(""));
		}
		
		
		if(this.getOptionType()==null || this.getOptionType().equals("")){
			
			ru.setMsg("对应操作类型不能为空！");
			
			errors.add("",new ActionMessage(""));
		}
		
		
		if(this.getIfLimitTime().equals("01") && this.getLimitTime()==0){
			
			ru.setMsg("限制使用次数不能为空！");
			
			errors.add("",new ActionMessage(""));
		}
		
		
		
		return errors;
	}
	
	
	
	public java.lang.Integer getId() {
		return id;
	}
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public java.lang.String getOptionType() {
		return optionType;
	}
	public void setOptionType(java.lang.String optionType) {
		this.optionType = optionType;
	}
	public java.lang.String getSummary() {
		return summary;
	}
	public void setSummary(java.lang.String summary) {
		this.summary = summary;
	}
	public java.lang.Integer getLimitTime() {
		return limitTime;
	}
	public void setLimitTime(java.lang.Integer limitTime) {
		this.limitTime = limitTime;
	}
	
	public float getServicePrice() {
		return servicePrice;
	}
	public void setServicePrice(float servicePrice) {
		this.servicePrice = servicePrice;
	}
	public java.lang.Integer getMonthLimit() {
		return monthLimit;
	}
	public void setMonthLimit(java.lang.Integer monthLimit) {
		this.monthLimit = monthLimit;
	}
	public java.lang.String getIfLimitTime() {
		return ifLimitTime;
	}
	public void setIfLimitTime(java.lang.String ifLimitTime) {
		this.ifLimitTime = ifLimitTime;
	}
	public java.lang.String getServiceName() {
		return serviceName;
	}
	public void setServiceName(java.lang.String serviceName) {
		this.serviceName = serviceName;
	}
	
	
	


}
